<template>
  <div>
    <template v-if="storeOptions.length > 0">
      <a-radio-group
        v-if="component === 'radio'"
        v-bind="$attrs"
        v-model:value="modelValue"
        :options="storeOptions"
      ></a-radio-group>
      <a-select
        v-bind="$attrs"
        v-else
        v-model:value="modelValue"
        :options="storeOptions"
        allow-clear
      ></a-select>
    </template>

    <div v-else class="text-gray-400">没有数据</div>
  </div>
</template>

<script setup lang="ts">
import { getStoreOptions, storeOptions } from '@/api/modules/utils/data';

const modelValue = defineModel<string>('modelValue');
withDefaults(
  defineProps<{
    component?: 'radio' | 'select';
  }>(),
  {
    component: 'radio',
  },
);
onMounted(() => {
  getStoreOptions();
});
</script>

<style lang="scss" scoped></style>
